<template>
 <view class="main">
   <view class="logo">
 	<image src="https://ppp.new.zeroitem.cn/ppp/logo.png" class="img1"></image>   
   </view>
   <view class="part1">
	 <view class="zp1">
		<view class="zp1-1">拍摄日期选择</view> 
		<view class="mp1-3">
		 请点击下方日历，选择您要拍摄的日期。蓝色选择日期代表当前日期已经被预定，无法选择。
		</view> 
	 </view> 
	 
	 
 <view class="cal">  
   <view class="cp1">
   		<view class="cp1-1">{{sdatestr1}}</view> 
   </view>	
   <view class="cp3">
   		<view class="cp3-1">一</view>
   		<view class="cp3-1">二</view>
   		<view class="cp3-1">三</view>
   		<view class="cp3-1">四</view>
   		<view class="cp3-1">五</view>
   		<view class="cp3-1">六</view>
		<view class="cp3-1">日</view>
   </view>

   <view class="cp4" v-for="item1 in cal1">
   		<view class="cp4-1" :class="[{'cur2':sday==item2.day&&stype==1},{'cur1':item2.cur==1}]" v-for="item2 in item1" @click="sdays1(item2.day,item2.cur,item2.zt)">
   		<view class="mp1"></view>
   		<view class="mp2">{{item2.day}}</view>
   		<view class="mp3"></view>	
   		</view> 
     </view>		  
   </view>
   
   
 <view class="cal">
   <view class="cp1">
   		<view class="cp1-1">{{sdatestr2}}</view> 
   </view>	
   <view class="cp3">
   		<view class="cp3-1">一</view>
   		<view class="cp3-1">二</view>
   		<view class="cp3-1">三</view>
   		<view class="cp3-1">四</view>
   		<view class="cp3-1">五</view>
   		<view class="cp3-1">六</view>
 		<view class="cp3-1">日</view>
   </view>
 
   <view class="cp4" v-for="item3 in cal2">
   		<view class="cp4-1" :class="[{'cur2':sday==item4.day&&stype==2},{'cur1':item4.cur==1}]" v-for="item4 in item3" @click="sdays2(item4.day,item4.cur,item4.zt)">
   		<view class="mp1"></view>
   		<view class="mp2">{{item4.day}}</view>
   		<view class="mp3"></view>	
   		</view> 
     </view>		  
   </view> 
	 <view class="btns" @click="qrpdate">确认选择日期</view> 
   </view>
   
 </view>
</template>
<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
		toLogin
	} from '@/utils/login'
	
	import {
		loadingFun,
		menuJump
	} from '@/utils/tools'	
	import {
	  mycal
	} from '@/api/ppp'		
    import {
		loadingType
	} from '@/utils/type'
	
	const app = getApp()
	export default {
		data() {
			return {
	          'cal1':[],
			  'cal2':[],
			  'uid':0,
			  'yid':0,
			  'zt':'',
			  'sdate1':"",
			  'sdatestr1':"",
			  'sdate2':"",
			  'sdatestr2':"",
			  'sday':-1,
			  'stype':0
			}
		},
		onLoad(options) {
		 if(options.uid!=0 && options.uid!=undefined){
		   this.uid=options.uid; 
		 }
		 if(options.yid!=0 && options.yid!=undefined){
		   this.yid=options.yid; 
		 }
		 this.getcal();
		},
		onShow() {
         
		},

		onReachBottom() {
	    
		},
		onPullDownRefresh() {

		},

		methods: {
		  qrpdate(){
			var stype=this.stype;
			if(stype==0){
			 uni.showToast({title:"请选择预定的日期",icon:"none"});
			 return false;
			}
			if(stype==1){
			 var pdate=this.sdate1+"-"+this.sday;
			}
			if(stype==2){
			 var pdate=this.sdate2+"-"+this.sday;	
			}
			let pages = getCurrentPages();  //获取所有页面栈实例列表
			let nowPage = pages[ pages.length - 1];  //当前页页面实例
			let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
			prevPage.$vm.pdate =pdate;   //修改上一页data里面的searchVal参数值为1211
			prevPage.$vm.setzt(this.zt);
			uni.navigateBack({  //uni.navigateTo跳转的返回，默认1为返回上一级
				delta: 1
			});  
		  },
		  sdays1(d,cur,zt){
			if(cur==1){
			  uni.showToast({title:"当前日期无法预定",icon:"none"});
			  return false;
			}
			if(d!='' && d>0){
			  this.stype=1;
			  this.sday=d;
			  this.zt=zt;
			}
			this.qrpdate();
		  },
		  sdays2(d,cur,zt){
			if(cur==1){
			  uni.showToast({title:"当前日期无法预定",icon:"none"});	
			  return false;
			}  
			if(d!='' && d>0){
			  this.stype=2;
			  this.sday=d;
			  this.zt=zt;
			}
			this.qrpdate();
		  },		   
          async getcal(){
			var uid=this.uid;
			var yid=this.yid;
			const{
			 code,
			  msg,
			  data
			}= await mycal({uid:uid,yid:yid});
			
			if(code==1){ 
			  this.cal1=data.cal1;
			  this.cal2=data.cal2;
			  this.sdate1=data.sdate1;
			  this.sdate2=data.sdate2;
			  this.sdatestr1=data.sdatestr1;
			  this.sdatestr2=data.sdatestr2;
			}  
		  }
		},
		computed: {
			...mapGetters(['isLogin']),
		}
	}
</script>
<style>
 @import "./pcalendar.css";	
</style>
